﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SAC.Elink;
using SAC.sqlHelper;

public partial class main2 : System.Web.UI.Page
{
    public double gl1 = 0;
    public double gl2 = 0;
    public double gl0 = 0;

    public double glzl1 = 0;
    public double glzl2 = 0;
    public double glzl0 = 0;

    public double wg1 = 0;
    public double wg2 = 0;
    public double wg0 = 0;

    public double wgzl1 = 0;
    public double wgzl2 = 0;
    public double wgzl0 = 0;

    public double ml1 = 0;
    public double ml2 = 0;
    public double ml0 = 0;

    public double srb1 = 0;
    public double srb2 = 0;
    public double srb0 = 0;

    public double gr1 = 0;
    public double gr2 = 0;
    public double gr0 = 0;

    public double zq1 = 0;
    public double zq2 = 0;
    public double zq0 = 0;

    public double zqyl1 = 0;
    public double zqyl2 = 0;
    public double zqyl0 = 0;

    public double zqwd1 = 0;
    public double zqwd2 = 0;
    public double zqwd0 = 0;

    public double zrwd1 = 0;
    public double zrwd2 = 0;
    public double zrwd0 = 0;

    public double zk1 = 0;
    public double zk2 = 0;
    public double zk0 = 0;

    public double lv1 = 0;
    public double lv2 = 0;
    public double lv0 = 0;

    public double rlv1 = 0;
    public double rlv2 = 0;
    public double rlv0 = 0;

    public double agcImg1 = 0;
    public double agcImg2 = 0;
    public double agcImg0 = 0;


    public double src1 = 0;
    public double src2 = 0;

    public string dtNow = "";

    public double fdl1 = 0;
    public double fdl2 = 0;
    public double fdl0 = 0;

    public double sw1 = 0;
    public double sw2 = 0;
    public double sw0 = 0;

    public double rml1 = 0;
    public double rml2 = 0;
    public double rml0 = 0;

    public double ryl1 = 0;
    public double ryl2 = 0;
    public double ryl0 = 0;

    public double tfdl1 = 0;
    public double tfdl2 = 0;
    public double tfdl0 = 0;

    public double tsw1 = 0;
    public double tsw2 = 0;
    public double tsw0 = 0;

    public double yfdl1 = 0;
    public double yfdl2 = 0;
    public double yfdl0 = 0;

    public double ysw1 = 0;
    public double ysw2 = 0;
    public double ysw0 = 0;

    public double yrml1 = 0;
    public double yrml2 = 0;
    public double yrml0 = 0;

    public double nsw1 = 0;
    public double nsw2 = 0;
    public double nsw0 = 0;

    public double nrml1 = 0;
    public double nrml2 = 0;
    public double nrml0 = 0;

    public double nfdl1 = 0;
    public double nfdl2 = 0;
    public double nfdl0 = 0;

    public string ywc1;
    public string ywc2;
    public string ywc0;

    public string nwc1;
    public string nwc2;
    public string nwc0;

    public string ydjh;
    public string ndjh;

    public string aqts;
    public string dtss;

    public string ycw1;
    public string ycw2;
    public string ycw0;

    public string ncw1;
    public string ncw2;
    public string ncw0;

    protected void Page_Load(object sender, EventArgs e)
    {
        Elink ek = new Elink();

        #region 实时数据赋值

        //有功功率
        string pgl1 = "WHSIS.U1APSH.U1A04013";
        string pgl2 = "WHSIS.U2APSH.U2A04013";

        gl1 = ek.GetRTValue(pgl1);
        gl2 = ek.GetRTValue(pgl2);

        gl0 = gl1 + gl2;

        //有功指令
        string pglzl1 = "WHSIS.U1APSH.U1A03658";
        string pglzl2 = "WHSIS.U2APSH.U2A03658";

        glzl1 = ek.GetRTValue(pglzl1);
        glzl2 = ek.GetRTValue(pglzl2);

        glzl0 = glzl1 + glzl2;

        //无功功率
        string wgp1 = "WHSIS.U1APSH.U1A01271";
        string wgp2 = "WHSIS.U2APSH.U2A01271";

        wg1 = ek.GetRTValue(wgp1);
        wg2 = ek.GetRTValue(wgp2);

        wg0 = wg1 + wg2;

        //无功指令
        string wgzlp1 = "WHSIS.U1APSH.U1A01271";
        string wgzlp2 = "WHSIS.U2APSH.U2A01271";

        wgzl1 = ek.GetRTValue(wgzlp1);
        wgzl2 = ek.GetRTValue(wgzlp2);

        wgzl0 = wgzl1 + wgzl2;

        //煤量
        string mlp1 = "WHSIS.U1APSH.U1A03662";
        string mlp2 = "WHSIS.U2APSH.U2A03662";

        ml1 = ek.GetRTValue(mlp1);
        ml2 = ek.GetRTValue(mlp2);

        ml0 = ml2 + ml1;

        //水燃比
        string sr1 = "WHSIS.CALC.CALC0006";
        string sr2 = "WHSIS.CALC.CALC2006";

        srb1 = ek.GetRTValue(sr1);
        srb2 = ek.GetRTValue(sr2);

        srb0 = srb1 + srb2;

        //过热度
        string grp1 = "WHSIS.U1APSH.U1A03725";
        string grp2 = "WHSIS.U2APSH.U2A03725";

        gr1 = ek.GetRTValue(grp1);
        gr2 = ek.GetRTValue(grp2);

        gr0 = gr1 + gr2;

        //主汽
        string zqp1 = "WHSIS.U1APSH.U1A04278";
        string zqp2 = "WHSIS.U2APSH.U2A04278";

        zq1 = ek.GetRTValue(zqp1);
        zq2 = ek.GetRTValue(zqp2);

        zq0 = zq1 + zq2;

        //主汽压力
        string zqylp1 = "WHSIS.CALC.CALC0001";
        string zqylp2 = "WHSIS.CALC.CALC2001";

        zqyl1 = ek.GetRTValue(zqylp1);
        zqyl2 = ek.GetRTValue(zqylp2);

        zqyl0 = zqyl2 + zqyl1;

        //主汽温度
        string zqwdp1 = "WHSIS.CALC.CALC0003";
        string zqwdp2 = "WHSIS.CALC.CALC2003";

        zqwd1 = ek.GetRTValue(zqwdp1);
        zqwd2 = ek.GetRTValue(zqwdp2);

        zqwd0 = zqwd2 + zqwd1;

        //再热温度
        //string zrwdp1 = "WHSIS.UNIV.ZBAVG003";
        //string zrwdp2 = "WHSIS.UNIV.ZBAVG203";
        string zrwdp1 = "WHSIS.CALC.CALC0002";
        string zrwdp2 = "WHSIS.CALC.CALC2002";

        zrwd1 = ek.GetRTValue(zrwdp1);
        zrwd2 = ek.GetRTValue(zrwdp2);

        zrwd0 = zrwd2 + zrwd1;

        //真空
        string zkp1 = "WHSIS.U1APSH.U1A00943";
        string zkp2 = "WHSIS.CALC.ZK";

        zk1 = ek.GetRTValue(zkp1);
        zk2 = ek.GetRTValue(zkp2);

        zk0 = zk1 + zk2;

        //炉效
        string lvp1 = "WHSIS.FUNPSH.U1.XN_Eta_b";
        string lvp2 = "WHSIS.FUNPSH.U2.XN_Eta_b";

        if (gl1 < 200)
            lv1 = 0;
        else
            lv1 = ek.GetRTValue(lvp1);

        if (gl2 < 200)
            lv2 = 0;
        else
            lv2 = ek.GetRTValue(lvp2);

        //热耗
        string rlvp1 = "WHSIS.FUNPSH.U1.XN_q0_rh";
        string rlvp2 = "WHSIS.FUNPSH.U2.XN_q0_rh";

        if (gl1 < 200)
            rlv1 = 0;
        else
            rlv1 = ek.GetRTValue(rlvp1);

        if (gl2 < 200)
            rlv2 = 0;
        else
            rlv2 = ek.GetRTValue(rlvp2);

        //热耗
        string AGC1 = "WHSIS.U1DPSH.U1D05405";
        string AGC2 = "WHSIS.U2DPSH.U2D05405";

        agcImg1 = ek.GetRTValue(AGC1);
        agcImg2 = ek.GetRTValue(AGC2);

        if (agcImg1 == 1.0 || agcImg1 == -1.0)
            this.img1.Src = "img/right.bmp";
        else
            this.img1.Visible = false;

        if (agcImg2 == 1.0 || agcImg2 == -1.0)
            this.img2.Src = "img/right.bmp";
        else
            this.img2.Visible = false;

        #endregion

        #region 运行信息

        //////////////////////////

        DateTime dt = DateTime.Now.AddDays(-1);

        dtNow = dt.ToString("yyyy-MM-dd");

        dtss = DateTime.Now.ToString("yyyy-MM-dd");

        object obj;
        string bm = "";
        string sql = "";
        string qsrq = "";
        string jsrq = "";
        string errMsg = "";

        string pID1 = "fdj1zxyg";               //1号机组电量编号
        string pID2 = "fdj2zxyg";               //2号机组电量编号

        string xl1ID1 = "zb1zxyg";              //天瑞2836线主表正向有功 xl1zxyg              
        string xl2ID1 = "zb2zxyg";              //天瑞2836线主表正向有功 xl1zxyg 

        //日值
        qsrq = dt.ToString("yyyy-MM-dd 0:00:00");
        jsrq = dt.AddDays(+1).ToString("yyyy-MM-dd 00:00:00");

        SAC.Power.PowerCale pc = new SAC.Power.PowerCale();

        fdl1 = double.Parse(pc.GetPower(fdl1, pID1, qsrq, jsrq, bm).ToString()) / 10000;
        fdl2 = double.Parse(pc.GetPower(fdl2, pID2, qsrq, jsrq, bm).ToString()) / 10000;

        fdl0 = fdl2 + fdl1;

        sw1 = double.Parse(pc.GetPower(sw1, xl1ID1, qsrq, jsrq, bm).ToString()) / 10000;
        sw2 = double.Parse(pc.GetPower(sw2, xl2ID1, qsrq, jsrq, bm).ToString()) / 10000;

        sw0 = sw1 + sw2;

        //燃煤量
        sql = "select sum(煤量1) from 入炉煤质分析表  where 日期 BETWEEN '" + qsrq + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "'";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            rml1 = double.Parse(obj.ToString());

        sql = "select sum(煤量2) from 入炉煤质分析表  where 日期 BETWEEN '" + qsrq + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "'";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            rml2 = double.Parse(obj.ToString());

        sql = "select sum(煤量1)+sum(煤量2) from 入炉煤质分析表  where 日期 BETWEEN '" + qsrq + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "'";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            rml0 = double.Parse(obj.ToString());

        //燃油量
        sql = "SELECT sum(用油量) FROM 用油量数据表  where 日期 BETWEEN '" +  DateTime.Parse(qsrq).ToString("yyyy-01-01 0:00:00") + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "' and 机组=1";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            ryl1 = double.Parse(obj.ToString());

        sql = "select sum(用油量) from 用油量数据表  where 日期 BETWEEN '" + DateTime.Parse(qsrq).ToString("yyyy-01-01 0:00:00") + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "' and 机组=2";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            ryl2 = double.Parse(obj.ToString());

        sql = "select sum(用油量) from 用油量数据表  where 日期 BETWEEN '" + DateTime.Parse(qsrq).ToString("yyyy-01-01 0:00:00") + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "'";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            ryl0 = double.Parse(obj.ToString());

        //月累计

        qsrq = dt.ToString("yyyy-MM-01 0:00:00");
        jsrq = dt.AddDays(+1).ToString("yyyy-MM-dd 00:00:00");

        yfdl1 = double.Parse(pc.GetPower(yfdl1, pID1, qsrq, jsrq, bm).ToString()) / 10000;
        yfdl2 = double.Parse(pc.GetPower(yfdl2, pID2, qsrq, jsrq, bm).ToString()) / 10000;

        yfdl0 = yfdl2 + yfdl1;

        ysw1 = double.Parse(pc.GetPower(ysw1, xl1ID1, qsrq, jsrq, bm).ToString()) / 10000;
        ysw2 = double.Parse(pc.GetPower(ysw2, xl2ID1, qsrq, jsrq, bm).ToString()) / 10000;

        ysw0 = ysw1 + ysw2;

        //燃煤量
        sql = "select sum(煤量1) from 入炉煤质分析表  where 日期 BETWEEN '" + qsrq + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "'";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            yrml1 = double.Parse(obj.ToString());

        sql = "select sum(煤量2) from 入炉煤质分析表  where 日期 BETWEEN '" + qsrq + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "'";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            yrml2 = double.Parse(obj.ToString());

        sql = "select sum(煤量1)+sum(煤量2) from 入炉煤质分析表  where 日期 BETWEEN '" + qsrq + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "'";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            yrml0 = double.Parse(obj.ToString());


        double daysM = DateTime.DaysInMonth(dt.Year, dt.Month);
        double dayM = dt.Day;

        //月度计划值
        sql = "SELECT 计划值 FROM 月度电量计划表 where 日期='" + qsrq + "' and 机组=1";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "0")
        {
            if (obj != null && obj.ToString() != "")
            {
                double wc1 = yfdl1 / double.Parse(obj.ToString()) * 100;
                ywc1 = wc1.ToString("f2");
                double cw1 = wc1 - dayM / daysM * 100;

                if (cw1 < 0)
                    ycw1 = "<font color=\"#FF0000\">" + cw1.ToString("f2") + "</font> ";
                else
                    ycw1 = cw1.ToString("f2");
            }
            else
            {
                ywc1 = "&nbsp;";
                ycw1 = "&nbsp;";
            }
        }
        else
        {
            ywc1 = "/";
            ycw1 = "/";
        }
        sql = "SELECT 计划值 FROM 月度电量计划表 where 日期='" + qsrq + "' and 机组=2";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null &&  obj.ToString() != "0")
        {
            if (obj != null && obj.ToString() != "")
            {
                double wc2 = yfdl2 / double.Parse(obj.ToString()) * 100;
                ywc2 = wc2.ToString("f2");
                double cw2 = wc2 - dayM / daysM * 100;


                if (cw2 < 0)
                    ycw2 = "<font color=\"#FF0000\">" + cw2.ToString("f2") + "</font> ";
                else
                    ycw2 = cw2.ToString("f2");


            }
            else
            {
                ywc2 = "&nbsp;";
                ycw2 = "&nbsp;";
            }
        }
        else
        {
            ywc2 = "/";
            ycw2 = "/";
        }
        sql = "SELECT 计划值 FROM 月度电量计划表 where 日期='" + qsrq + "' and 机组=0";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null &&  obj.ToString() != "0")
        {
            if (obj != null && obj.ToString() != "")
            {
                ydjh = obj.ToString();
                double wc3 = yfdl0 / double.Parse(obj.ToString()) * 100;
                ywc0 = wc3.ToString("f2");
                double cw3 = wc3 - dayM / daysM * 100;

                if (cw3 < 0)
                    ycw0 = "<font color=\"#FF0000\">" + cw3.ToString("f2") + "</font> ";
                else
                    ycw0 = cw3.ToString("f2");

            }
            else
            {
                ydjh = "&nbsp;";
                ywc0 = "&nbsp;";
                ycw0 = "&nbsp;";
            }
        }
        else
        {
            ywc0 = "/";
            ycw0 = "/";
        }


        //同期
        qsrq = dt.AddYears(-1).ToString("yyyy-MM-01 0:00:00");
        jsrq = dt.AddYears(-1).AddDays(+1).ToString("yyyy-MM-dd 00:00:00");

        tfdl1 = double.Parse(pc.GetPower(tfdl1, pID1, qsrq, jsrq, bm).ToString()) / 10000;
        tfdl2 = double.Parse(pc.GetPower(tfdl2, pID2, qsrq, jsrq, bm).ToString()) / 10000;

        tfdl0 = tfdl2 + tfdl1;

        tsw1 = double.Parse(pc.GetPower(tsw1, xl1ID1, qsrq, jsrq, bm).ToString()) / 10000;
        tsw2 = double.Parse(pc.GetPower(tsw2, xl2ID1, qsrq, jsrq, bm).ToString()) / 10000;

        tsw0 = tsw1 + tsw2;

        //年累计
        qsrq = dt.ToString("yyyy-01-01 0:00:00");
        jsrq = dt.AddDays(+1).ToString("yyyy-MM-dd 00:00:00");

        nfdl1 = double.Parse(pc.GetPower(nfdl1, pID1, qsrq, jsrq, bm).ToString()) / 10000;
        nfdl2 = double.Parse(pc.GetPower(nfdl2, pID2, qsrq, jsrq, bm).ToString()) / 10000;

        nfdl0 = nfdl2 + nfdl1;

        nsw1 = double.Parse(pc.GetPower(nsw1, xl1ID1, qsrq, jsrq, bm).ToString()) / 10000;
        nsw2 = double.Parse(pc.GetPower(nsw2, xl2ID1, qsrq, jsrq, bm).ToString()) / 10000;

        nsw0 = nsw1 + nsw2;

        //燃煤量
        sql = "select sum(煤量1) from 入炉煤质分析表  where 日期 BETWEEN '" + qsrq + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "'";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            nrml1 = double.Parse(obj.ToString());

        sql = "select sum(煤量2) from 入炉煤质分析表  where 日期 BETWEEN '" + qsrq + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "'";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            nrml2 = double.Parse(obj.ToString());

        sql = "select sum(煤量1)+sum(煤量2) from 入炉煤质分析表  where 日期 BETWEEN '" + qsrq + "' AND '" + DateTime.Parse(jsrq).AddDays(-1).ToString("yyyy-MM-dd 23:59:59") + "'";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
            nrml0 = double.Parse(obj.ToString());

        double daysY = this.retDaysInYear(dt);
        double dayY = this.retDayYear(dt);

        //年度计划值
        sql = "SELECT 计划值 FROM 年度电量计划表 where 日期='" + qsrq + "' and 机组=1";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null &&  obj.ToString() != "0")
        {
            if (obj != null && obj.ToString() != "")
            {
                double wc1 = nfdl1 / double.Parse(obj.ToString()) * 100;
                nwc1 = wc1.ToString("f2");

                double cw1 = wc1 - dayY / daysY * 100;

                if (cw1 < 0)
                    ncw1 = "<font color=\"#FF0000\">" + cw1.ToString("f2") + "</font> ";
                else
                    ncw1 = cw1.ToString("f2");
            }
            else
            {
                ncw1 = "&nbsp;";
                nwc1 = "&nbsp;";
            }
        }
        else
        {

            ncw1 = "/";
            nwc1 = "/";
        }
        sql = "SELECT 计划值 FROM 年度电量计划表 where 日期='" + qsrq + "' and 机组=2";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null &&  obj.ToString() != "0")
        {
            if (obj != null && obj.ToString() != "")
            {
                double wc2 = nfdl2 / double.Parse(obj.ToString()) * 100;
                nwc2 = wc2.ToString("f2");

                double cw2 = wc2 - dayY / daysY * 100;

                if (cw2 < 0)
                    ncw2 = "<font color=\"#FF0000\">" + cw2.ToString("f2") + "</font> ";
                else
                    ncw2 = cw2.ToString("f2");

            }
            else
            {
                nwc2 = "&nbsp;";
                ncw2 = "&nbsp;";
            }
        }
        else
        {
            nwc2 = "/";
            ncw2 = "/";

        }
        sql = "SELECT 计划值 FROM 年度电量计划表 where 日期='" + qsrq + "' and 机组=0";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null &&  obj.ToString() != "0")
        {
            if (obj != null && obj.ToString() != "")
            {
                ndjh = obj.ToString();
                double wc3 = nfdl0 / double.Parse(obj.ToString()) * 100;
                nwc0 = wc3.ToString("f2");

                double cw3 = wc3 - dayY / daysY * 100;

                if (cw3 < 0)
                    ncw0 = "<font color=\"#FF0000\">" + cw3.ToString("f2") + "</font> ";
                else
                    ncw0 = cw3.ToString("f2");
            }
            else
            {
                ndjh = "&nbsp;";
                nwc0 = "&nbsp;";
                ncw0 = "&nbsp;";
            }
        }
        else
        {
            nwc0 = "/";
            ncw0 = "/";
        }


        //安全天数
        sql = " SELECT 开始日期 FROM 安全天数事件表";

        obj = DBsql.RunSingle(sql, out errMsg);

        if (obj != null && obj.ToString() != "")
        {
            TimeSpan ts = DateTime.Now.AddDays(-1) - DateTime.Parse(obj.ToString());
            aqts = ts.Days.ToString();
        }
        else
            aqts = "&nbsp;";

        this.img0.Src = "img/yj.gif";

        string pN = "WHSIS.CALC.BAOJING";

        double pv = ek.GetRTValue(pN);

        if (pv == 1.0)
            this.img0.Visible = true;
        else
            this.img0.Visible = false;
        #endregion
    }


    private double retDaysInYear(DateTime dt)
    {
        DateTime qsrq;
        DateTime jsrq;

        TimeSpan ts;

        qsrq = DateTime.Parse(dt.ToString("yyyy-01-01 0:00:00"));
        jsrq = DateTime.Parse(dt.AddYears(+1).ToString("yyyy-01-01 0:00:00"));

        ts = jsrq - qsrq;

        if (ts.Days > 0)
        {
            return ts.Days;
        }
        else { return 0; }
    }

    private double retDayYear(DateTime dt)
    {
        DateTime qsrq;
        DateTime jsrq;

        TimeSpan ts;

        qsrq = DateTime.Parse(dt.ToString("yyyy-01-01 0:00:00"));
        jsrq = DateTime.Parse(dt.ToString("yyyy-MM-dd 0:00:00"));

        ts = jsrq - qsrq;

        if (ts.Days > 0)
        {
            return ts.Days + 1;
        }
        else { return 0; }
    }

    protected void btnRec1_Click(object sender, EventArgs e)
    {
        Response.Redirect("../xtt/ednaview.asp?File=WHSIS.APP:ALL\\WGT.rtv");
    }
}
